Skip to content

Auto-import libraries based on sketch profile. #2951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jul 11, 2025

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Jul 11, 2025

Please check if the PR fulfills these requirements

See how to contribute

  • The PR has no duplicates (please search among the Pull Requests
    before creating one)
  • The PR follows
    our contributing guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • UPGRADING.md has been updated with a migration guide (for breaking changes)
  • configuration.schema.json updated if new parameters are added.

What kind of change does this PR introduce?

This PR changes the way libraries are imported when using sketch profiles.

What is the current behavior?

The libraries specified on profiles are "loaded" in the global state. Still, they are imported and compiled only if referenced by the sketch (or indirectly by a library imported from the sketch) after the so-called "library discovery".

What is the new behavior?

The libraries specified on profiles are always imported and compiled, even if not referenced directly or indirectly by the sketch.
This reduces the number of "library discovery" passes and slightly improves compilation times. Still, the main part of the library discovery phase remains.

Does this PR introduce a breaking change, and is titled accordingly?

It might introduce a breaking change. For example, if a library is listed in a sketch profile but not used in the sketch, after this update, the library will still be compiled, leading to a compilation failure.

Other information

@cmaglie cmaglie self-assigned this Jul 11, 2025
@cmaglie cmaglie added type: enhancement Proposed improvement topic: build-process Related to the sketch build process labels Jul 11, 2025
@per1234 per1234 added the topic: code Related to content of the project itself label Jul 11, 2025
Copy link

codecov bot commented Jul 11, 2025

Codecov Report

Attention: Patch coverage is 69.44444% with 66 lines in your changes missing coverage. Please review.

Project coverage is 67.99%. Comparing base (3db4ad8) to head (07d9452).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
...nternal/arduino/builder/internal/detector/cache.go 70.31% 14 Missing and 5 partials ⚠️
...lder/internal/preprocessor/arduino_preprocessor.go 0.00% 16 Missing ⚠️
...rnal/arduino/builder/internal/detector/detector.go 83.63% 5 Missing and 4 partials ⚠️
...nal/arduino/builder/internal/preprocessor/ctags.go 45.45% 6 Missing ⚠️
...l/arduino/builder/internal/detector/source_file.go 88.63% 3 Missing and 2 partials ⚠️
internal/arduino/libraries/libraries_location.go 44.44% 5 Missing ⚠️
...ernal/arduino/builder/internal/preprocessor/gcc.go 33.33% 4 Missing ⚠️
commands/service_compile.go 50.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2951      +/-   ##
==========================================
- Coverage   68.01%   67.99%   -0.03%     
==========================================
  Files         238      239       +1     
  Lines       22567    22589      +22     
==========================================
+ Hits        15350    15360      +10     
- Misses       6015     6025      +10     
- Partials     1202     1204       +2     
Flag Coverage Δ
unit 67.99% <69.44%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@alessio-perugini alessio-perugini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cmaglie cmaglie merged commit ae68728 into arduino:master Jul 11, 2025
104 checks passed
@cmaglie cmaglie deleted the improve_lib_discovery_in_profiles branch July 11, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: build-process Related to the sketch build process topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants